import axios from 'axios'

export function getRanking (callback) {
  axios('/vkey/v8/fcg-bin/fcg_myqq_toplist.fcg', {
    params: {
      '_': '1561519741997',
      g_tk: 5381,
      uin: 0,
      format: 'json',
      inCharset: 'utf-8',
      outCharset: 'utf-8',
      notice: 0,
      platform: 'h5',
      needNewCode: 1
    }
  }).then((response) => {
    callback(response)
  }).catch((error) => {
    callback(error)
  })
}

export function getRankingList (rid, callback) {
  axios('/api/cgi-bin/musicu.fcg', {
    params: {
      '-': 'getUCGI7306956346245095',
      g_tk: 5381,
      loginUin: 0,
      hostUin: 0,
      format: 'json',
      inCharset: 'utf8',
      outCharset: 'utf-8',
      notice: 0,
      platform: 'yqq.json',
      needNewCode: 0,
      data: {
        'detail': {
          'module': 'musicToplist.ToplistInfoServer',
          'method': 'GetDetail',
          'param': {'topId': rid, 'offset': 0, 'num': 20, 'period': '2019-06-23'}
        },
        'comm': {'ct': 24, 'cv': 0}
      }
    }
  }).then((response) => {
    callback(response)
  }).catch((error) => {
    callback(error)
  })
}